<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" import="java.util.*,java.io.*,java.sql.*,java.text.*, dbAccess.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Admin Remove Admin</title>
<link rel="stylesheet" type="text/css" href="css_files/style.css" />
</head>
<body>
<table width="100%" border="1" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="178" height="125" valign="top"><img src="images/caduceus.gif" alt="" name="LogoLeft" width="150" height="125" id="LogoLeft" style="background-color: #0033FF" /></td>
    <td width="616" align="center" valign="middle"><h1 align="center">CADUCEUS HOSPITAL </h1></td>
    <td width="231" valign="top"><img src="images/hospital.jpg" alt="" name="LogoRight" width="180" height="119" id="LogoRight" style="background-color: #0033FF" /></td>
  </tr>
  <tr>
    <td height="19" colspan="2" valign="top">Welcome Admin. <%=session.getAttribute("Name")%>&nbsp;<%=new java.util.Date() %></td>
  	<td><a href="home.jsp" title="Logout">Logout</a></td>
  </tr>
</table>

<table width="100%" height="34" border="1" align="left">
      <thead>
        <tr>
          <td width="80"><div align="center"><strong>Staff Id</strong></div></td>
          <td width="80"><div align="center"><strong>Staff First Name</strong></div></td>
          <td width="80"><div align="center"><strong>Staff Last Name</strong></div></td>
          <td width="80"><div align="center"><strong>Email Address</strong></div></td>
          <td width="80"><div align="center"><strong>Gender</strong></div></td>
          <td width="80"><div align="center"><strong>Date of Birth</strong></div></td>
          <td width="80"><div align="center"><strong>Phone</strong></div></td>
          <td width="80"><div align="center"><strong>Home Address</strong></div></td>
          <td width="80"><div align="center"><strong>Password</strong></div></td>
          <td width="80"><div align="center"><strong>Doctor</strong></div></td>
          <td width="80"><div align="center"><strong>Update</strong></div></td>
          <td width="80"><div align="center"><strong>Delete</strong></div></td>
         </tr>
        </thead>
        <tbody>
        <%
        
        Login lgn = new Login();
		ResultSet rs;
		int Id = 0;
		String FirstName = "unknown";
		String LastName = "unknown";
		String emailAddress = "unknown";
		String gender = "unknown";
		String dateOfBirth= "unknown";
		String phone = "unknown";
		String homeAddress = "unknown";
		String password = "unknown";		

		rs = lgn.getStaffListForAdmin("Admin");
		if (rs != null)
		{
			while (rs.next())
			{
				Id = rs.getInt("tbl_staff.StaffId");
				FirstName = rs.getString("tbl_staff.FirstName");
				LastName = rs.getString("tbl_staff.LastName");
				emailAddress = rs.getString("tbl_staff.EmailAddress");
				gender = rs.getString("tbl_staff.Gender");
				phone = rs.getString("tbl_staff.Phone");
				homeAddress = rs.getString("tbl_staff.HomeAddress");
				password = rs.getString("tbl_staff.Password");
				dateOfBirth = rs.getString("tbl_staff.DateOfBirth");
				
        	%>
				
        		<tr>
				<form name="updateAdmin" method="post" action="staffAddSaveByAdmin.jsp?action=update&staffId=<%=Id%>">
        			<td>
        				<%=Id%>
        			</td>
        			<td>
        				<input name="firstName" type="text" id="firstName" value = <%=FirstName%> />
        			</td>
        			<td>
        				<input name="lastName" type="text" id="lastName" value = <%=LastName%> />
        			</td>
        			<td>
        				<input name="emailAddress" type="text" id="emailAddress" value = <%=emailAddress%> />
        			</td>
        			<td>
        				<%
						if (gender.equals("M"))
						{
						%>
					 	<input name="gender" type="radio" value="male" checked/> Male
					 	<input name="gender" type="radio" value="female"/> Female
						<%	
						}
						else
						{
						%>
					 	<input name="gender" type="radio" value="male"/> Male
					 	<input name="gender" type="radio" value="female" checked/> Female
						<%		
						}
						%>
        			</td>
        			<td>
        				<input name="dateOfBirth" type="text" id="dateOfBirth" value = <%=dateOfBirth%> />
        			</td>
        			<td>
        				<input name="phone" type="text" id="phone" value = <%=phone%> />
        			</td>
        			<td>
        				<input name="homeAddress" type="text" id="homeAddress" value = <%=homeAddress%> />
        			</td>
        			<td>
        				<input name="password" type="text" id="password" value = <%=password%> />
        			</td>
        			
			<td>
				<select id="cmbDoctor" name="cmbDoctor">
					<%
						DbAccess access = new DbAccess();
						ResultSet rs2;
						int docId;
						String docFirstName;
						String docLastName;
						String option;
						String query = "select tbl_doctor.DocId, tbl_doctor.FirstName, tbl_doctor.LastName ";
						query += "from tbl_doctor where tbl_doctor.IsDeleted = 0 ";
						query += "order by tbl_doctor.LastName";
						rs2 = access.ExecuteSelect(access.connect(), query);
					if (rs2 != null)
					{
						while (rs2.next())
						{
							docLastName = rs2.getString("tbl_doctor.LastName").trim();
							docFirstName = rs2.getString("tbl_doctor.FirstName").trim();
							docId = rs2.getInt("tbl_doctor.DocId");
							option = docLastName + "," + docFirstName + "-" + docId;
						%>
						<option><%=option%></option>
					<%	
						}
					}
					%>
				</select>
			</td>
        			
        			<td>
        					<input name="Update" type="submit" id="Update" value="Update" />
        			</td>
        			<td>        				
        			<form name="removeAdmin" method="post" action="removeDocSave.jsp?staffId=<%=Id%>">
        					<input name="adminRemove" type="submit" id="adminRemove" value="Delete Staff" />
        				</form>
        			</td>
        		</tr>
        		
        	<%
			}
		}
        %>
        </tbody>
      </table>      
</body>
</html>